Renaming elements
A very instrumental function to quickly edit ST-code is the renaming of elements, also known as refactoring of the code.
How to refactor code within the ST-editor:
-
Position onto an →identifier that you have already used repeatedly within ST-objects and/or PLC-objects.
Example: In the declaration of a variableVAR var1 : INT; VAR_END
go tovar1
. -
Open the context menu of the ST-editor and select Rename Element.
-
Enter the new identifier and press the Enter-key.
Observe: In case of a changed name and if this variable is already used, the corresponding code is refactored:
-
All usages of an internal or external variable in the current object are automatically renamed to the new name.
-
All usages of an input or output variable in the objects (e.g. ST-/FBD-objects) of the current project are automatically renamed to the new name.
Restriction for renaming a global or external variable The corresponding counterpart is not automatically renamed. |
Alternative for refactoring the element name, started from within the project explorer: See "Changing the name of an element".